package angry.courses.entities;
import javax.persistence.*;

@Entity
@Table(name="relations")
@NamedQueries({
	@NamedQuery(name="retrieveSidsForCid", query="SELECT r.sid FROM RelationEntity r WHERE r.cid=:cid"),
	@NamedQuery(name="retrieveCidsForSid", query="SELECT r.cid FROM RelationEntity r WHERE r.sid=:sid"),
	@NamedQuery(name="retrieveRelationsForSid", query="SELECT r FROM RelationEntity r WHERE r.sid=:sid"),
	@NamedQuery(name="retrieveRelationsForCid", query="SELECT r FROM RelationEntity r WHERE r.cid=:cid")
})
public class RelationEntity implements java.io.Serializable {

	//create table relations(rid int NOT NULL AUTO_INCREMENT PRIMARY KEY, cid int NOT NULL, sid int NOT NULL, 
	//						 	FOREIGN KEY (cid) references courses(cid), 
	//							FOREIGN KEY (sid) references students(sid));

	@Id
	@GeneratedValue
	@Column(name="rid",nullable=false)
	int rid;

	@Column(name="cid",nullable=false)
	int cid;

	@Column(name="sid",nullable=false)
	int sid;

	public RelationEntity() {}
	
	public RelationEntity(int cId,int sId) {
		this.cid = cId;
		this.sid = sId;
	}

	public int getCourseID() { 	
		return cid;
	}

	public int getStudentID() {
		return sid;
	}

	public int getRelationID() {
		return rid;
	}
}
